/*
** player.c for player in /home/faye_m//zappy
** 
** Made by mouhamed faye
** Login   <faye_m@epitech.net>
** 
** Started on  Thu Jun 30 13:13:01 2011 mouhamed faye
** Last update Fri Jul  1 12:55:43 2011 mouhamed faye
*/
#include <stdio.h>
#include <stdlib.h>
#include "player.h"
#include "team.h"
Class_player	*add_player(Class_player *list_players, int socket)
{
  Class_player  *new_player;
  new_player = malloc(10 * sizeof(*new_player));
  if(new_player == NULL)
    printf ("add_player segfault the server");
  else
    {
      new_player->num_joueur = socket;
      new_player->ttl_joueur = 0;
      new_player->nb_player += 1;
      new_player->max_req += 1;
      new_player->next = NULL;
      if (list_players ==  NULL)
	return(new_player);
      else
	{
	  Class_player	*tmp = list_players;
	  while (tmp->next != NULL)
	    tmp =  tmp->next;
	  tmp->next =  new_player;
	}
      return (list_players);
    }
  return (NULL);
}
